<template>
	<view class="info">
		<view class="header">
			<view class="title">
				工单信息
				<Tag :status="state" />
			</view>
		</view>
		<view class="body">
			<view class="form">
				<view class="form-item">
					<view class="label">
						工单号：
					</view>
					<view class="text">
						{{ data.workCode || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						工单组号：
					</view>
					<view class="text">
						{{ data.groupItem || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						工序：
					</view>
					<view class="text">
						{{ data.productionProcesses || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						生产顺序：
					</view>
					<view class="text">
						{{ data.sort || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						产品编号：
					</view>
					<view class="text">
						{{ data.materialCode || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						产品名称：
					</view>
					<view class="text">
						{{ data.materialName || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						产品型号：
					</view>
					<view class="text">
						{{ data.materialModel || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						图号规格：
					</view>
					<view class="text">
						{{ data.customMaterialCode || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						材料牌号：
					</view>
					<view class="text">
						{{ data.materialMark || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						模具编号：
					</view>
					<view class="text">
						{{ data.moldCode || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						模具名称：
					</view>
					<view class="text">
						{{ data.moldName || '--' }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						计划数量：
					</view>
					<view class="text">
						{{ data.planProduceQuantity }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						生产数量：
					</view>
					<view class="text">
						{{ data.produceQuantity }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						合格数量：
					</view>
					<view class="text">
						{{ data.qualifiedQuantity }}
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						报废数量：
					</view>
					<view class="text">
						{{ data.scrapQuantity }}
					</view>
				</view>
				<view class="form-item" v-if="!hideCuttingPlan && data.cuttingPlanCode">
					<view class="label">
						开料详情：
					</view>
					<view class="text" style="color:#5cb3de" @click="openCuttingPlan">
						查看开料计划单
					</view>
				</view>
				<view class="form-item">
					<view class="label">
						备注：
					</view>
					<view class="text">
						{{ data.remarks || '--' }}
					</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<Button text @click="back">
				查看其他工单
			</Button>
			<Button type="success" @click="goto('/pages/workbench/index')" class="back_btn">
				返回主菜单
			</Button>
		</view>
	</view>
</template>

<script>
	import Tag from "@/components/tag/index.vue";
	import Button from "@/components/button/index.vue";
	import fetch from "@/utils/fetch";

	export default {
		props: {
			data: {
				type: Object,
				default: () => {
					return {
						state: '状态'
					}
				},
			},
			hideCuttingPlan: {
				type: Boolean,
				default: false
			},
			backUrl: {
				type: String,
				default: ''
			},
			state: {
				type: String,
				default: ''
			},
		},
		components: {
			Tag,
			Button,
		},
		data() {
			return {};
		},
		methods: {
			openCuttingPlan() {
				this.$emit('openCuttingPlan');
			},
			goto(url) {
				uni.navigateTo({
					url,
					animationType: "pop-in",
					animationDuration: 1000,
				})
			},
			back() {
				uni.navigateBack(-1)
				// if (this.backUrl) {
				// 	this.goto(this.backUrl);
				// } else {
				// 	uni.navigateBack(-1)
				// }
			}
		}
	}
</script>

<style lang="scss">
	.info {
		flex: 1;
		display: flex;
		flex-direction: column;
		height: 100%;

		.header {
			flex: 0 auto;
			padding: 0 3rem;

			.title {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				padding: 2rem 0;
				border-bottom: 1px solid #ccc;
				font-weight: bold;
			}
		}

		.body {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 5rem 5rem 0;

			.form {
				flex: 1;

				.form-item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin: 0 0 3rem;

					.label {
						color: #999;
						flex: 1;
					}

					.text {
						color: #333;
						width: 26rem;
						word-break: break-all;
					}

					&:last-child {
						margin-bottom: 0;
					}
				}
			}
		}

		.footer {
			flex: 0 auto;
			padding: 0 3rem 3rem;
		}

		.text_btn {
			margin-top: 3rem;
		}

		.back_btn {
			margin-top: 2rem;
		}
	}
</style>